package malus.shaofeng.com.beiwomusic.model;

import com.lidroid.xutils.db.annotation.Column;
import com.lidroid.xutils.db.annotation.Foreign;
import com.lidroid.xutils.db.annotation.Id;
import com.lidroid.xutils.db.annotation.NoAutoIncrement;
import com.lidroid.xutils.db.annotation.Table;

import org.json.JSONObject;

import java.io.Serializable;
import java.util.LinkedList;

/**
 * Created by aaa on 15-3-10.
 */
@Table(name = "artist")
public class Artist implements Serializable{
               @Id(column = "artist_id")
               @NoAutoIncrement
               private long artist_id;// 573,
               @Column(column = "artist_name")
               private String artist_name;// "李宗盛",
               @Column(column = "image_uri")
               private String image_uri;// "/mnt/res.nmting.com/res/qms/jpg/91/fb/91fba5ae299a42ce827c186c580ffd35.jpg"
               @Foreign(column = "newStoryMusicId",foreign = "music_id")
               private NewStoryMusic newStoryMusic;

    public void parseJSON(JSONObject json){
        if (json!=null){
                      artist_id=json.optLong("artist_id");
                      artist_name=json.optString("artist_name");
                      image_uri=json.optString("image_uri");
        }
    }

    public long getArtist_id() {
        return artist_id;
    }

    public void setArtist_id(long artist_id) {
        this.artist_id = artist_id;
    }

    public String getArtist_name() {
        return artist_name;
    }

    public void setArtist_name(String artist_name) {
        this.artist_name = artist_name;
    }

    public String getImage_uri() {
        return image_uri;
    }

    public void setImage_uri(String image_uri) {
        this.image_uri = image_uri;
    }

    public NewStoryMusic getNewStoryMusic() {
        return newStoryMusic;
    }

    public void setNewStoryMusic(NewStoryMusic newStoryMusic) {
        this.newStoryMusic = newStoryMusic;
        if (newStoryMusic.getArtists()==null){
            newStoryMusic.setArtists(new LinkedList<Artist>());
        }
        newStoryMusic.getArtists().add(this);
    }
}
